package com.ruoyi.oto.service.impl;

import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.entity.MemberUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.oto.constants.CompanyShowFlag;
import com.ruoyi.oto.constants.CompanyStatus;
import com.ruoyi.oto.constants.DeleteFlag;
import com.ruoyi.oto.domain.BranchLink;
import com.ruoyi.oto.domain.CompanyCore;
import com.ruoyi.oto.domain.CompanyType;
import com.ruoyi.oto.domain.dto.CompanyQuryDTO;
import com.ruoyi.oto.domain.dto.CompanyRegDTO;
import com.ruoyi.oto.mapper.BranchLinkMapper;
import com.ruoyi.oto.mapper.CompanyCoreMapper;
import com.ruoyi.oto.service.BranchLinkService;
import com.ruoyi.oto.service.CompanyCoreService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 联企人员和企业的绑定关系
 *
 * @author ruoyi
 */
@Service
public class BranchLinkServiceImpl extends ServiceImpl<BranchLinkMapper, BranchLink> implements BranchLinkService
{
    @Override
    public void deleteAllByCompanyId(Long companyId) {
        this.remove(new LambdaQueryWrapper<BranchLink>().eq(BranchLink::getCompanyId, companyId));
    }

    @Override
    public List<Long> getCompanyIdsByMemberId(Long memberId) {
        return this.list(new LambdaQueryWrapper<BranchLink>().eq(BranchLink::getMemberId,memberId).eq(BranchLink::getDelFlag,DeleteFlag.NO)).stream().map(BranchLink::getCompanyId).collect(Collectors.toList());
    }
}
